USERNAME = group14
ASSIGNMENT = 08
SERVER = 138.232.64.210
PORT = 22113
FILES = ConnectionHandlerHTTPS.cpp ConnectionHandlerRelay.cpp httpsc.cpp httpsd.cpp tlsproxy.cpp assignment08.txt SSLWrapper.hpp

CXXFLAGS += -O0 -Wall -g
CXXFLAGS += $(shell pkg-config --cflags libssl)
LDFLAGS += $(shell pkg-config --libs libssl)

BINS = httpsd httpsc tlsproxy httpd

SRCS =                                         ConnectionHandlerHTTP.cpp ConnectionHandlerHTTPS.cpp ConnectionHandlerRelay.cpp ConnectSocket.cpp GenericException.cpp httpd.cpp httpsc.cpp httpsd.cpp        ListenSocket.cpp                           TCPConnection.cpp hexdump.cpp
HDRS = BoundedBuffer.hpp ConnectionHandler.hpp ConnectionHandlerHTTP.hpp ConnectionHandlerHTTPS.hpp ConnectionHandlerRelay.hpp ConnectSocket.hpp GenericException.hpp                                 IP.hpp ListenSocket.hpp Logger.hpp SSLWrapper.hpp TCPConnection.hpp
OBJS =                                         ConnectionHandlerHTTP.o   ConnectionHandlerHTTPS.o   ConnectionHandlerRelay.o   ConnectSocket.o   GenericException.o                                          ListenSocket.o                             TCPConnection.o   hexdump.o

DEPSFILE = .depend

.PHONY: upload sense clean

all: $(BINS)

upload:
	touch check
	scp -P $(PORT) check $(FILES) $(USERNAME)@$(SERVER):assignment$(ASSIGNMENT)

sense:
	scp -P $(PORT) $(USERNAME)@$(SERVER):log.txt $(USERNAME)@$(SERVER):compile.log .
	tail compile.log log.txt

clean:
	rm -f $(BINS) $(OBJS) $(DEPSFILE) check log.txt compile.log

$(BINS): %: %.cpp $(HDRS) $(OBJS) $(DEPSFILE)
	$(CXX) $(CFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $< $(OBJS)

$(DEPSFILE): $(SRCS)
	$(CXX) -MM $(SRCS) > $(DEPSFILE)

-include $(DEPSFILE)
